package com.twu.exercise;

public class FizzBuzz {
    private String separator = System.getProperty("line.separator");

    public String fizzBuzz() {
        StringBuilder result = new StringBuilder();
        for (int index=1;index<101;index++) {
            StringBuilder sequence = new StringBuilder();
            if (isDivisibleByThree(index)) sequence.append("Fizz");
            if (isDivisibleByFive(index)) sequence.append("Buzz");
            if (sequence.length()==0) sequence.append(index);
            sequence.append(separator);
            result.append(sequence);
        }
        return result.toString();
    }

    private boolean isDivisibleByThree(int number) {
        return number%3==0;
    }

    private boolean isDivisibleByFive(int number) {
        return number%5==0;
    }
}
